package com.aifund.common.entity;

import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单
 */
@Entity
@SQLDelete(sql = "update ai_order set delete = 1 where id = ?")
@Where(clause = "is_del = 0")
@Data
@EntityListeners(AuditingEntityListener.class)
public class AiOrder {

    @Id
    @GeneratedValue
    private Long id;

    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 订单状态
     */
    private Integer orderStatus;

    /**
     * 交易所ID
     */
    private Long exchangeId;

    /**
     * 交易前拥有资金
     */
    private BigDecimal amount;

    /**
     * 投入资金
     */
    private BigDecimal volume;

    private String apiKey;

    private String apiPass;

    /**
     * 交易对
     */
    private String symbol;

    /**
     * 交易方向,买BUY 卖SELL
     */
    private String tradeSide;

    /**
     * 仓位
     */
    private Double storingLocation;


    @CreatedDate
    @Column(name = "createTime",updatable = false,nullable = false)
    private Date createTime;

    @LastModifiedDate
    @Column(name = "updateTime",nullable = false)
    private Date updateTime;

    @Type(type = "org.hibernate.type.NumericBooleanType")
    private Boolean isDel = false;





}
